<template>
  <div class="crud-button">
    <el-button type="primary" @click="onEdit(data.row)">编辑</el-button>
    <el-button
      type="warning"
      @click="onRestore(data.row)"
      v-if="data.row.isDeleted"
      >找回</el-button
    >
    <el-button type="danger" @click="onDelete(data.row)" v-else>删除</el-button>
    <slot />
  </div>
</template>

<script>
// import { deletes, restore } from "@/api/admin/tentant";
import { ElMessage, ElMessageBox } from 'element-plus'
export default {
  props: {
    data: {
      required: true,
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {};
  },
  methods: {
    onEdit(row) {
      this.$emit("onEdit", row);
    },
    onRestore(row) {
      let _this = this
      ElMessageBox.confirm("确认找回？")
        .then((_) => {
          _this.$emit("onRestore", row);
        })
        .catch((_) => {});
    },
    onDelete(row) {
      let _this = this
      ElMessageBox.confirm("确认删除？")
        .then((_) => {
          _this.$emit("onDelete", row);
        })
        .catch((_) => {});
    },
  },
  watch: {},
};
</script>

<style lang="scss" scoped>
.crud-button button {
  margin: 0 5px;
}
</style>